home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / comm / tcp / Amster-source.lha / Amster_Install / Source / resultview.c < prev    next >
C/C++ Source or Header  |  2001-03-14  |  19KB  |  670 lines

  1. /*
  2. ** Amster - Result View
  3. ** Copyright © 1999-2000 by Gürer Özen
  4. ** Copyright © 2000-2001 by Jacob Laursen
  5. **
  6. ** This program is free software; you can redistribute it and/or modify
  7. ** it under the terms of the GNU General Public License as published by
  8. ** the Free Software Foundation; either version 2 of the License, or
  9. ** (at your option) any later version.
  10. **
  11. ** This program is distributed in the hope that it will be useful,
  12. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ** GNU General Public License for more details.
  15. **
  16. ** You should have received a copy of the GNU General Public License
  17. ** along with this program; if not, write to the Free Software
  18. ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. */
  20.  
  21. #include "amster.h"
  22.  
  23. #include <proto/dos.h>
  24.  
  25. #include <MUI/Lamp_mcc.h>
  26. #include <MUI/NListview_mcc.h>
  27.  
  28. #include "amster_Cat.h"
  29.  
  30. /* Private prototypes */
  31.  
  32. ULONG resultview_new(struct IClass *cl, Object *obj, struct opSet *msg);
  33. Object *ResultviewContextMenuBuild(struct IClass *cl, Object *obj, struct MUIP_NList_ContextMenuBuild *msg);
  34. MUI_LIST_DISP_DECL(resultlistdisp, song s);
  35. MUI_NLIST_COMP_DECL(resultlistcomp);
  36. void resultview_clear(struct resultdata *data, int t);
  37. void resultview_download(struct resultdata *data, int t, int num);
  38. void resultview_nick(struct resultdata *data, char *nick);
  39. void resultview_stat(struct resultdata *data, int t);
  40. void resultview_found(struct resultdata *data, song s);
  41. void resultview_reset(struct resultdata *data);
  42. void resultview_fillstem(struct resultdata *data, char *stem);
  43.  
  44. struct MUI_CustomClass *ResultviewContext;
  45.  
  46. /* Global variables */
  47.  
  48. char *gColFormat;
  49. int gContextChoice;
  50.  
  51.  
  52. MUI_DISPATCH(resultview_dispatch)
  53. {
  54.     struct resultdata *data;
  55.  
  56.     switch (msg->MethodID) {
  57.         case OM_NEW:
  58.             return(resultview_new(cl, obj, (APTR)msg));
  59.         case RESULTVIEW_CLEAR:
  60.             data = INST_DATA(cl, obj);
  61.             resultview_clear(data, (int)(((muimsg)msg)->arg1));
  62.             return NULL;
  63.         case RESULTVIEW_DOWNLOAD:
  64.             data = INST_DATA(cl, obj);
  65.             resultview_download(data, (int)(((muimsg)msg)->arg1), (int)(((muimsg)msg)->arg2));
  66.             return NULL;
  67.         case RESULTVIEW_FOUND:
  68.             data = INST_DATA(cl, obj);
  69.             resultview_found(data, (song)(((muimsg)msg)->arg1));
  70.             return NULL;
  71.         case RESULTVIEW_TOGGLE_BOTH:
  72.             {
  73.             u_long tmp;
  74.             data = INST_DATA(cl, obj);
  75.             GetAttr(MUIA_Selected, data->fptog, &tmp);
  76.             prf->fullpath = tmp;
  77.             DoMethod(gui->searchpanel, SEARCH_TOGGLE);
  78.             DoMethod(gui->WI_Hotlist, HOTLIST_TOGGLE);
  79.             return NULL;
  80.             }
  81.         case RESULTVIEW_TOGGLE_ONE:
  82.             data = INST_DATA(cl, obj);
  83.             set(data->fptog, MUIA_Selected, prf->fullpath);
  84.             DoMethod(data->list, MUIM_NList_Redraw, MUIV_NList_Redraw_All);
  85.             return NULL;
  86.         case RESULTVIEW_STAT:
  87.             data = INST_DATA(cl, obj);
  88.             set(data->result, MUIA_Text_Contents, (char *)(((muimsg)msg)->arg1));
  89.             return NULL;
  90.         case RESULTVIEW_STAT2:
  91.             data = INST_DATA(cl, obj);
  92.             resultview_stat(data, (int)(((muimsg)msg)->arg1));
  93.             return NULL;
  94.         case RESULTVIEW_INSERT:
  95.             data = INST_DATA(cl, obj);
  96.             DoMethod(data->list, MUIM_NList_InsertSingle, (song)(((muimsg)msg)->arg1), MUIV_NList_Insert_Sorted);
  97.             return NULL;
  98.         case RESULTVIEW_NICK:
  99.             {
  100.             data = INST_DATA(cl, obj);
  101.             resultview_nick(data, (char *)(((muimsg)msg)->arg1));
  102.             return NULL;
  103.             }
  104.         case RESULTVIEW_RESETCOUNT:
  105.             data = INST_DATA(cl, obj);
  106.             data->resultview_count = 0;
  107.             return NULL;
  108.         case RESULTVIEW_GETSTATE:
  109.             data = INST_DATA(cl, obj);
  110.             search_state = data->resultview_state;
  111.             return NULL;
  112.         case RESULTVIEW_FILLSTEM:
  113.             data = INST_DATA(cl, obj);
  114.             resultview_fillstem(data, (char *)(((muimsg)msg)->arg1));
  115.             return NULL;
  116.         case RESULTVIEW_ADDTOHOTLIST:
  117.             {
  118.             song item;
  119.             data = INST_DATA(cl, obj);
  120.             DoMethod(data->list, MUIM_NList_GetEntry, gContextChoice, &item);
  121.             if (item) {
  122.                 DoMethod(gui->WI_Hotlist, HOTLIST_ADD, item->user);
  123.             }
  124.             return NULL;
  125.             }
  126.         case RESULTVIEW_NICKFROMLIST:
  127.             {
  128.             song item;
  129.             data = INST_DATA(cl, obj);
  130.             DoMethod(data->list, MUIM_NList_GetEntry, gContextChoice, &item);
  131.             if (item) {
  132.                 DoMethod(gui->searchpanel, SEARCH_NICK, item->user);
  133.             }
  134.             return NULL;
  135.             }
  136.     }
  137.     return(DoSuperMethodA(cl, obj, msg));
  138. }
  139.  
  140.  
  141. ULONG resultview_new(struct IClass *cl, Object *obj, struct opSet *msg)
  142. {
  143.     static struct Hook resultlistdispHook = { {0,0}, &resultlistdisp, NULL, NULL };
  144.     static struct Hook resultlistcompHook = { {0,0}, &resultlistcomp, NULL, NULL };
  145.     struct resultdata *data;
  146.  
  147.     Object *result, *list;
  148.     Object *BT_Clear, *BT_ClearAll, *BT_Download, *fptog;
  149. /*    Object *BT_Resume;*/
  150.  
  151.     /* Determine wether to use a context menu or not! */
  152.     if (GetTagData(MUIA_Amster_ContextMenu, FALSE, msg->ops_AttrList)) list = NewObject(ResultviewContext->mcc_Class, NULL,
  153.         InputListFrame,
  154.         MUIA_NList_Title, TRUE,
  155.         MUIA_NList_Format, gColFormat,
  156.         MUIA_NList_MinColSortable, 0,
  157.         MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Default,
  158.         MUIA_NList_DisplayHook, &resultlistdispHook,
  159.         MUIA_NList_CompareHook2, &resultlistcompHook,
  160.         MUIA_CycleChain, 1);
  161.     else list = NListObject,
  162.         InputListFrame,
  163.         MUIA_NList_Title, TRUE,
  164.         MUIA_NList_Format, gColFormat,
  165.         MUIA_NList_MinColSortable, 0,
  166.         MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Default,
  167.         MUIA_NList_DisplayHook, &resultlistdispHook,
  168.         MUIA_NList_CompareHook2, &resultlistcompHook,
  169.         MUIA_CycleChain, 1);
  170.  
  171.     if (obj = (Object *)DoSuperNew(cl, obj,
  172.         Child, VGroup,
  173.             Child, HGroup,
  174.                 Child, Label(MSG_RESULT),
  175.                 Child, result = TextObject, End,
  176.             End,
  177.             Child, NListviewObject,
  178.                 MUIA_NListview_NList, list,
  179. /*
  180.                 MUIA_NListview_NList, list = NewObject(ResultviewContext->mcc_Class, NULL,
  181.                     InputListFrame,
  182.                     MUIA_NList_Title, TRUE,
  183.                     MUIA_NList_Format, gColFormat,
  184.                     MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Default,
  185.                     MUIA_NList_DisplayHook, &resultlistdispHook,
  186.                     MUIA_NList_CompareHook2, &resultlistcompHook,
  187.                     MUIA_CycleChain, 1,
  188.                 End,
  189. */
  190.             End,
  191.             Child, HGroup,
  192.                 Child, BT_Clear    = SimpleButton(MSG_CLEAR_GAD),
  193.                 Child, BT_ClearAll = SimpleButton(MSG_CLEARALL_GAD),
  194. /*                Child, BT_Resume   = SimpleButton(MSG_RESUME_GAD),*/
  195.                 Child, BT_Download = SimpleButton(MSG_DOWNLOAD_GAD),
  196.                 Child, TextObject,
  197.                     MUIA_HorizWeight, 25,
  198.                     MUIA_Text_PreParse, "\33r",
  199.                     MUIA_Text_Contents, MSG_SEARCH_FULLPATH,
  200.                 End,
  201.                 Child, fptog = ImageObject,
  202.                     ButtonFrame,
  203.                     MUIA_HorizWeight, 10,
  204.                     MUIA_Background, MUII_ButtonBack,
  205.                     MUIA_InputMode, MUIV_InputMode_Toggle,
  206.                     MUIA_ShowSelState, FALSE,
  207.                     MUIA_Image_Spec, "6:15",
  208.                     MUIA_Selected, prf->fullpath,
  209.                 End,
  210.             End,
  211.         End,
  212.         TAG_MORE, msg->ops_AttrList))
  213.     {
  214.         data = INST_DATA(cl, obj);
  215.         data->result = result;
  216.         data->list = list;
  217. /*        data->BT_Resume = BT_Resume;*/
  218.         data->BT_Clear = BT_Clear;
  219.         data->BT_ClearAll = BT_ClearAll;
  220.         data->BT_Download = BT_Download;
  221.         data->fptog = fptog;
  222.  
  223.         lamp_useinlist(list);
  224.  
  225.         DoMethod(BT_Clear,    MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, RESULTVIEW_CLEAR, CLEAR_MARKED);
  226.         DoMethod(BT_ClearAll, MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, RESULTVIEW_CLEAR, CLEAR_ALL   );
  227.         DoMethod(BT_Download, MUIM_Notify, MUIA_Pressed, FALSE, obj, 3, RESULTVIEW_DOWNLOAD, 0, 0);
  228. /*        DoMethod(BT_Resume,   MUIM_Notify, MUIA_Pressed, FALSE, obj, 3, RESULTVIEW_DOWNLOAD, 2, 0);*/
  229.         DoMethod(list, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 3, RESULTVIEW_DOWNLOAD, 1, 0);
  230.  
  231.         DoMethod(fptog, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, obj, 1, RESULTVIEW_TOGGLE_BOTH);
  232.  
  233.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick,  MUIV_EveryTime, list, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  234.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick2, MUIV_EveryTime, list, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  235.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType,    MUIV_EveryTime, list, 3, MUIM_Set, MUIA_NList_TitleMark,  MUIV_TriggerValue);
  236.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType2,   MUIV_EveryTime, list, 3, MUIM_Set, MUIA_NList_TitleMark2, MUIV_TriggerValue);
  237.  
  238.         return((ULONG)obj);
  239.     }
  240.     return NULL;
  241. }
  242.  
  243.  
  244. MUI_DISPATCH(ResultviewContextDispatcher)
  245. {
  246.     switch (msg->MethodID)
  247.     {
  248.         case MUIM_NList_ContextMenuBuild:
  249.             return (ULONG) ResultviewContextMenuBuild(cl, obj, (struct MUIP_NList_ContextMenuBuild *)msg);
  250.             break;
  251.         case MUIM_ContextMenuChoice:
  252.             {
  253.             int item = muiUserData(((struct MUIP_ContextMenuChoice *)msg)->item);
  254.             switch (item) {
  255.                 case 0:
  256.                     DoMethod(gui->searchpanel, SEARCH_ADDTOHOTLIST);
  257.                     break;
  258.                 case 1:
  259.                     DoMethod(gui->searchpanel, SEARCH_NICKFROMLIST);
  260.                     break;
  261.             }
  262.             return NULL;
  263.             }
  264.     }
  265.     return(DoSuperMethodA(cl, obj, msg));
  266. }
  267.  
  268.  
  269. Object *ResultviewContextMenuBuild(struct IClass *cl, Object *obj, struct MUIP_NList_ContextMenuBuild *msg)
  270. {
  271.     struct ResultviewContextData *data = INST_DATA(cl, obj);
  272.  
  273.     if (msg->ontop || msg->pos == -1) {
  274.         return NULL; /* Default context menu when pointer isn't on an entry */
  275.     }
  276.     else {
  277.         gContextChoice = msg->pos;
  278.         return (
  279.             MenustripObject,
  280.                 Child, MenuObject,
  281.                     MUIA_Menu_Title, MSG_MAINCONTEXTMENU_TITLE,
  282.                     Child, data->MI_AddToHotlist = MenuitemObject,
  283.                         MUIA_Menuitem_Title, MSG_MAINCONTEXTMENU_ADD,
  284.                         MUIA_UserData, 0,
  285.                     End,
  286.                     Child, data->MI_BrowseUser = MenuitemObject,
  287.                         MUIA_Menuitem_Title, MSG_MAINCONTEXTMENU_BROWSE,
  288.                         MUIA_UserData, 1,
  289.                     End,
  290.                 End,
  291.             End);
  292.     }
  293. }
  294.  
  295.  
  296. MUI_LIST_DISP(resultlistdisp, song s)
  297. {
  298.     static char buf[50], buf2[50], buf3[50], time[40];
  299.  
  300.     if (s) {
  301.         if (s->link == 0)
  302.             *array++ = lamp_getforlist(0);
  303.         else if(s->link < 5)
  304.             *array++ = lamp_getforlist(1);
  305.         else if(s->link < 8)
  306.             *array++ = lamp_getforlist(2);
  307.         else
  308.             *array++ = lamp_getforlist(3);
  309.  
  310.         if (prf->fullpath)
  311.             *array++ = s->title;
  312.         else
  313.             *array++ = nap_strippath(s->title);
  314.  
  315.         sprintf(buf,"\33c%d",s->bit);
  316.         *array++ = buf;
  317.         sprintf(buf2,"\33c%d",s->freq);
  318.         *array++ = buf2;
  319.         sprintf(buf3,"\33r%ld",s->size);
  320.         *array++ = buf3;
  321.  
  322.         if (s->time>0) {
  323.             int secs = s->size/(s->bit*125);
  324.             if (abs(s->time - secs)*100/s->time > 3)
  325.                 sprintf(time, "\33r\33i%ld:%02ld", s->time/60, s->time%60);
  326.             else
  327.                 sprintf(time, "\33r%ld:%02ld", s->time/60, s->time%60);
  328.         }
  329.         else {
  330.             sprintf(time,"\33r0:00");
  331.         }
  332.         *array++ = time;
  333.  
  334.         *array++ = s->user;
  335.         *array = nap_linktype[s->link];
  336.     }
  337.     else {
  338.         *array++ = "\33c@";
  339.         *array++ = (char *)MSG_LH_SONG;
  340.         *array++ = (char *)MSG_LH_KBPS;
  341.         *array++ = (char *)MSG_LH_HZ;
  342.         *array++ = (char *)MSG_LH_SIZE;
  343.         *array++ = (char *)MSG_LH_TIME;
  344.         *array++ = (char *)MSG_LH_USER;
  345.         *array   = (char *)MSG_LH_LINK;
  346.     }
  347.     return(0);
  348. }
  349.  
  350.  
  351. void resultview_clear(struct resultdata *data, int t)
  352. {
  353.     u_long item;
  354.  
  355.     switch(t) {
  356.         case CLEAR_MARKED:
  357.         {
  358.             u_long listid = MUIV_NList_NextSelected_Start;
  359.  
  360.             for (;;) {
  361.                 DoMethod(data->list, MUIM_NList_NextSelected, &listid);
  362.                 if (listid==MUIV_NList_NextSelected_End) break;
  363.                 DoMethod(data->list, MUIM_NList_GetEntry,listid, &item);
  364.                 if (item) {
  365.                     DoMethod(data->list, MUIM_NList_Remove, MUIV_NList_Remove_Selected);
  366.                     nap_songfree((song)item);
  367.                 }
  368.             }
  369.             break;
  370.         }
  371.  
  372.         case CLEAR_ALL:
  373.             set(data->list,MUIA_NList_Quiet, MUIV_NList_Quiet_Visual);
  374.             while (1) {
  375.                 DoMethod(data->list, MUIM_NList_GetEntry, 0, &item);
  376.                 if(!item) break;
  377.                 DoMethod(data->list, MUIM_NList_Remove, MUIV_NList_Remove_First);
  378.                 nap_songfree((song)item);
  379.             }
  380.             set(data->list,MUIA_NList_Quiet, MUIV_NList_Quiet_None);
  381.             resultview_stat(data, 0);
  382.             break;
  383.     }
  384. }
  385.  
  386.  
  387. void resultview_download(struct resultdata *data, int t, int num)
  388. {
  389.     int f=0;
  390.     u_long item, listid;
  391.  
  392.     if (gui_onlinestate < ONLINE) {
  393.         gRC = 10;
  394.         return;
  395.     }
  396.  
  397.     switch (t) {
  398.         case 0:
  399.             listid = MUIV_NList_NextSelected_Start;
  400.             for (;;) {
  401.                 DoMethod(data->list, MUIM_NList_NextSelected, &listid);
  402.                 if (listid == MUIV_NList_NextSelected_End) break;
  403.                 DoMethod(data->list, MUIM_NList_GetEntry, listid, &item);
  404.                 if (item) {
  405.                     if (!f) {
  406.                         DoMethod(gui->iconpanel, PANEL_OPENDL);
  407.                         f=1;
  408.                     }
  409.                     dl_addq((song)item);
  410.                 }
  411.             }
  412.             break;
  413.  
  414.         case 1:
  415.             GetAttr(MUIA_NList_DoubleClick, data->list, &listid);
  416.             if (listid == -1 || listid == -2) return;
  417.             DoMethod(data->list, MUIM_NList_GetEntry, listid, &item);
  418.             if (!item) return;
  419.             if (!f) {
  420.                 DoMethod(gui->iconpanel, PANEL_OPENDL);
  421.                 f=1;
  422.             }
  423.             dl_addq((song)item);
  424.             break;
  425.  
  426.         case 2:
  427.             DoMethod(data->list, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &item);
  428.             if (!item) return;
  429. #ifdef AMSTER_DEBUG
  430. gui_debugf("Resume attempted for: %s", ((song)item)->title);
  431. #endif
  432.             break;
  433.  
  434.         case 3:
  435.             DoMethod(data->list, MUIM_NList_GetEntry, num, &item);
  436.             if (item) {
  437.                 if (!f) {
  438.                     f=1;
  439.                 }
  440.                 dl_addq((song)item);
  441.             }
  442.             else gRC = 9;
  443.             break;
  444.     }
  445. }
  446.  
  447.  
  448. void resultview_nick(struct resultdata *data, char *nick)
  449. {
  450.     if (gui_onlinestate < ONLINE) return;
  451.  
  452.     data->resultview_count = 0;
  453.     if (prf->clrlist) resultview_clear(data, CLEAR_ALL);
  454.     nap_sendbuf(NAPC_BROWSEUSER, nick);
  455.     resultview_stat(data, 3);
  456. }
  457.  
  458.  
  459. void resultview_stat(struct resultdata *data, int t)
  460. {
  461.     static char buf[80];
  462.     char *txt;
  463.  
  464.     switch(t) {
  465.         case 0:
  466.             txt = "";
  467.             data->resultview_state = 0;
  468.             break;
  469.  
  470.         case 1:
  471.             data->resultview_state = 1;
  472.             txt = (char *)MSG_STATUS1_SEARCHING;
  473.             break;
  474.  
  475.         case 2:
  476.             if (data->resultview_count == 0)
  477.                 txt = (char*)MSG_STATUS1_NOFILES;
  478.             else if (data->resultview_count == 1)
  479.                 txt = (char*)MSG_STATUS1_ONEFOUND;
  480.             else {
  481.                 sprintf(buf, MSG_STATUS1_FOUND, data->resultview_count);
  482.                 txt = buf;
  483.             }
  484.             data->resultview_state = 2;
  485.             break;
  486.  
  487.         case 3:
  488.             txt = (char *)MSG_STATUS1_REQLIST;
  489.             break;
  490.     }
  491.  
  492.     set(data->result, MUIA_Text_Contents, txt);
  493. }
  494.  
  495.  
  496. void resultview_found(struct resultdata *data, song s)
  497. {
  498.     if (s) {
  499.         DoMethod(data->list, MUIM_NList_InsertSingle, s, MUIV_NList_Insert_Sorted);
  500.         data->resultview_count++;
  501.     }
  502.     else {
  503.         resultview_stat(data, 2);
  504.     }
  505. }
  506.  
  507.  
  508. MUI_NLIST_COMP(resultlistcomp)
  509. {
  510.     song entry1 = ncm->entry1;
  511.     song entry2 = ncm->entry2;
  512.     LONG col1 = ncm->sort_type & MUIV_NList_TitleMark_ColMask;
  513.     LONG col2 = ncm->sort_type2 & MUIV_NList_TitleMark2_ColMask;
  514.     ULONG result = 0;
  515.  
  516.     if (ncm->sort_type == MUIV_NList_SortType_None) return (0);
  517.  
  518.     if (col1 == 1) {
  519.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask) {
  520.             if (prf->fullpath) result = (LONG) stricmp(entry2->title, entry1->title);
  521.             else result = (LONG) stricmp(nap_strippath(entry2->title), nap_strippath(entry1->title));
  522.         }
  523.         else {
  524.             if (prf->fullpath) result = (LONG) stricmp(entry1->title, entry2->title);
  525.             else result = (LONG) stricmp(nap_strippath(entry1->title), nap_strippath(entry2->title));
  526.         }
  527.     }
  528.     else if (col1 == 2) {
  529.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  530.             result = entry2->bit - entry1->bit;
  531.         else
  532.             result = entry1->bit - entry2->bit;
  533.     }
  534.     else if (col1 == 3) {
  535.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  536.             result = entry2->freq - entry1->freq;
  537.         else
  538.             result = entry1->freq - entry2->freq;
  539.     }
  540.     else if (col1 == 4) {
  541.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  542.             result = entry2->size - entry1->size;
  543.         else
  544.             result = entry1->size - entry2->size;
  545.     }
  546.     else if (col1 == 5) {
  547.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  548.             result = entry2->time - entry1->time;
  549.         else
  550.             result = entry1->time - entry2->time;
  551.     }
  552.     else if (col1 == 6) {
  553.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  554.             result = (LONG) stricmp(entry2->user, entry1->user);
  555.         else
  556.             result = (LONG) stricmp(entry1->user, entry2->user);
  557.     }
  558.     else if (col1 == 7) {
  559.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  560.             result = entry2->link - entry1->link;
  561.         else
  562.             result = entry1->link - entry2->link;
  563.     }
  564.  
  565.     if ((result != 0) || (col1 == col2)) return (result);
  566.  
  567.     if (col2 == 1) {
  568.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask) {
  569.             if (prf->fullpath) result = (LONG) stricmp(entry2->title, entry1->title);
  570.             else result = (LONG) stricmp(nap_strippath(entry2->title), nap_strippath(entry1->title));
  571.         }
  572.         else {
  573.             if (prf->fullpath) result = (LONG) stricmp(entry1->title, entry2->title);
  574.             else result = (LONG) stricmp(nap_strippath(entry1->title), nap_strippath(entry2->title));
  575.         }
  576.     }
  577.     else if (col2 == 2) {
  578.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  579.             result = entry2->bit - entry1->bit;
  580.         else
  581.             result = entry1->bit - entry2->bit;
  582.     }
  583.     else if (col2 == 3) {
  584.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  585.             result = entry2->freq - entry1->freq;
  586.         else
  587.             result = entry1->freq - entry2->freq;
  588.     }
  589.     else if (col2 == 4) {
  590.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  591.             result = entry2->size - entry1->size;
  592.         else
  593.             result = entry1->size - entry2->size;
  594.     }
  595.     else if (col2 == 5) {
  596.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  597.             result = entry2->time - entry1->time;
  598.         else
  599.             result = entry1->time - entry2->time;
  600.     }
  601.     else if (col2 == 6) {
  602.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  603.             result = (LONG) stricmp(entry2->user, entry1->user);
  604.         else
  605.             result = (LONG) stricmp(entry1->user, entry2->user);
  606.     }
  607.     else if (col2 == 7) {
  608.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  609.             result = entry2->link - entry1->link;
  610.         else
  611.             result = entry1->link - entry2->link;
  612.     }
  613.  
  614.     return (result);
  615. }
  616.  
  617.  
  618. void resultview_fillstem(struct resultdata *data, char *stem)
  619. {
  620.     int i;
  621.     song item;
  622.     char buf[1024], buf2[32];
  623.     struct RexxMsg *m;
  624.     u_long tmp;
  625.  
  626.     GetAttr(MUIA_Application_RexxMsg, gui->app, &tmp);
  627.     m = (struct RexxMsg *)tmp;
  628.  
  629.     for (i=0; i<data->resultview_count; i++) {
  630.         DoMethod(data->list, MUIM_NList_GetEntry, i, &item);
  631.         if (item) {
  632.             sprintf(buf, "%s.%d.TITLE", stem, i);
  633.             SetRexxVar(m, buf, item->title, strlen(item->title));
  634.  
  635.             sprintf(buf, "%s.%d.MD5", stem, i);
  636.             SetRexxVar(m, buf, item->md5, strlen(item->md5));
  637.  
  638.             sprintf(buf, "%s.%d.SIZE", stem, i);
  639.             sprintf(buf2, "%ld", item->size);
  640.             SetRexxVar(m, buf, buf2, strlen(buf2));
  641.  
  642.             sprintf(buf, "%s.%d.BITRATE", stem, i);
  643.             sprintf(buf2, "%ld", item->bit);
  644.             SetRexxVar(m, buf, buf2, strlen(buf2));
  645.  
  646.             sprintf(buf, "%s.%d.FREQUENCY", stem, i);
  647.             sprintf(buf2, "%ld", item->freq);
  648.             SetRexxVar(m, buf, buf2, strlen(buf2));
  649.  
  650.             sprintf(buf, "%s.%d.TIME", stem, i);
  651.             sprintf(buf2, "%ld", item->time);
  652.             SetRexxVar(m, buf, buf2, strlen(buf2));
  653.  
  654.             sprintf(buf, "%s.%d.LINK", stem, i);
  655.             sprintf(buf2, "%d", item->link);
  656.             SetRexxVar(m, buf, buf2, strlen(buf2));
  657.  
  658.             sprintf(buf, "%s.%d.USER", stem, i);
  659.             SetRexxVar(m, buf, item->user, strlen(item->user));
  660.         }
  661.         else {
  662.             gRC = 10;
  663.             break;
  664.         }
  665.     }
  666.     sprintf(buf, "%s.COUNT", stem);
  667.     sprintf(buf2, "%d", data->resultview_count);
  668.     SetRexxVar(m, buf, buf2, strlen(buf2));
  669. }
  670.